package com.avic.rong.transform.api;

import com.avic.rong.api.HttpPostService;
import com.avic.rong.utils.ConstantsUtils;
import com.example.minato.minastore.BaseApi;
import com.example.minato.minastore.listener.HttpOnNextListener;
import com.orhanobut.logger.Logger;
import com.trello.rxlifecycle2.components.support.RxAppCompatActivity;

import io.reactivex.Observable;
import retrofit2.Retrofit;

/**
 * Created by Chenjiaxin on 2019/7/24 14:10
 * E-Mail Address：16601203965@163.com
 */
public class TransformApi extends BaseApi {

    private Integer typeId;
    private Integer catId;
    private Integer pageSize = 20;
    private String keyword = ConstantsUtils.EMPTY_STR;
    private Integer sort = 0;
    private Integer pageNo = 1;
    private int flag = 0;// 0：需求 1，供应


    public void setFlag(int flag) {
        this.flag = flag;
    }

    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }

    public void setTypeId(Integer typeId) {
        this.typeId = typeId;
    }

    public void setCatId(Integer catId) {
        this.catId = catId;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public void setSort(int sort) {
        this.sort = sort;
    }


    public TransformApi(RxAppCompatActivity rxAppCompatActivity, HttpOnNextListener listener,int flag) {
        super(rxAppCompatActivity, listener);
        this.flag = flag;

        setCache(false);
    }

    @Override
    public Observable getObservable(Retrofit retrofit) {
        HttpPostService service = retrofit.create(HttpPostService.class);
        Logger.i("--------------catId:--" + catId + "-----typeId:" + typeId + "----typeId:" + typeId + "----pageNo:" + pageNo);
        if (flag == 0) {
            return service.sdhallDh(typeId, sort, keyword, catId, pageNo, pageSize);
        } else {
            return service.sdhallSh(typeId, sort, keyword, catId, pageNo, pageSize);
        }
    }


}
